package com.neusoft.NursingHome.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.neusoft.NursingHome.po.NursingLevel;
import com.neusoft.NursingHome.po.ResponseBean;
import com.neusoft.NursingHome.service.NursingLevelService;

@RestController
@RequestMapping("/nursinglevel")
public class NursingLevelController {

    @Autowired
    private NursingLevelService nursingLevelService;

    /**
     * 返回所有的护理级别
     * @return 包含所有护理级别列表的 ResponseBean
     */
    @GetMapping("/all")
    public ResponseBean<List<NursingLevel>> getAllNursingLevels() {
        List<NursingLevel> nursingLevels = nursingLevelService.getAllNursingLevels();
        return new ResponseBean<>(nursingLevels);
    }

    /**
     * 添加新的护理级别
     * @param nursingLevel 护理级别对象
     * @return 添加结果的 ResponseBean
     */
    @PostMapping("/add")
    public ResponseBean<Boolean> addNursingLevel(@RequestBody NursingLevel nursingLevel) {
        boolean result = nursingLevelService.addNursingLevel(nursingLevel);
        return new ResponseBean<>(result);
    }

    /**
     * 更新护理级别的状态
     * @param levelId 护理级别的唯一标识符
     * @param status 新的状态值（0:停用 1:启用）
     * @return 更新结果的 ResponseBean
     */
    @PutMapping("/status")
    public ResponseBean<Boolean> updateNursingLevelStatus(
            @RequestParam Integer levelId,
            @RequestParam Integer status) {
        boolean result = nursingLevelService.updateNursingLevelStatus(levelId, status);
        return new ResponseBean<>(result);
    }

    /**
     * 根据状态查询护理级别
     * @param status 状态值（0:停用 1:启用）
     * @return 包含符合条件的护理级别列表的 ResponseBean
     */
    @GetMapping("/status/{status}")
    public ResponseBean<List<NursingLevel>> getNursingLevelsByStatus(@PathVariable Integer status) {
        List<NursingLevel> nursingLevels = nursingLevelService.getNursingLevelsByStatus(status);
        return new ResponseBean<>(nursingLevels);
    }
}